﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessClass.StateMachine.Core
{
    public class OptionalState<T> : ISate<T>
    {
        public bool Ignore { get; private set; }
        public ISate<T> InternalState { get; private set; }
        public OptionalState(bool ignore, ISate<T> s)
        {
            Ignore = ignore;
            InternalState = s;
        }
        public T Accept(Machine m)
        {
            if (Ignore)
            {
                return default(T);
            }
            return m.Visit(InternalState);
        }
    }
}
